<?php 

function post($url, $data, $posts=true)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, $posts?1:0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $data = curl_exec($ch);
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch); 
    if ($code != 200) {
        return false;
    }
    return json_decode($data, true);
}


// $url = 'http://www.weather.com.cn/data/sk/101110101.html';
// var_dump(post($url, ['name'=>'zhangsam', 'age'=>23]));

 ?>